import java.util.*;
public class demo02 {
    //回文日期
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num1=sc.nextInt();
        int num2=sc.nextInt();
        int count=0;
        for (int i = num1; i <= num2; i++) {
            int num=i;
            if(check(num)){
                count++;
            }
        }
        System.out.println(count);
    }
    public static boolean check(int num){
        int[] arr={0,31,28,31,30,31,30,31,31,30,31,30,31};
        int year=num/10000;
        int month=num%10000/100;
        int day=num%100;
        if (checkmonth(year)){
            arr[2]+=1;
        }
        if(month>12||month<1){
            return false;
        }
        if(day>arr[month]||day<1){
            return false;
        }
        String str=num+"";
        StringBuilder str1=new StringBuilder(str).reverse();
        return str.equals(str1.toString());
    }
    public static boolean checkmonth(int year){
        if((year%4==0&&year%100!=0)||(year%400==0)){
            return true;
        }
        return false;
    }
}
